/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-10-01
 * Time: 21:30
 */
public class Demo3 {
    private static int num;
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            synchronized (Demo2.class) {
                for(int i = 0; i < 100; i++) {
                    num++;
                }
            }
        });

        Thread t2 = new Thread(() -> {
            synchronized (Demo2.class) {
                for(int i = 0; i < 100; i++) {
                    num++;
                }
            }
        });

        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(num);
    }
}
